package sanrenxing.dayEnd.backRepertoryTotal.dao;


import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Statisical;

import java.util.List;

/**
 * 功能:
 * 编写者：
 * 日期：2021
 * 版本：1.0
 */
public interface StatisicalDao {

    /**
     * 分页查询条件
     *
     * @param start
     * @param rows
     * @param condition
     * @return
     */
    @Select("select s.seId,f.seName,s.secNum,s.costs,m.closePrice as Qprice,(m.openPrice/m.closePrice) marValue,(s.costs/m.closePrice) markets,\n" +
            "se.tranDate from securitiesStock s join marketData m on s.seId=m.seId join financialsecurities f on s.seId=f.seId \n" +
            "join securitiesTradingData se on s.seId=se.seId where se.tranStatus=1")
    public List<Statisical> findByPage(@Param("start") int start, @Param("rows") int rows, @Param("condition") String condition);

    /**
     * 按条件统计记录数
     *
     * @param condition 统计条件
     * @return 条件
     */
    @Select("select count(*) from securitiesStock s join marketData m on s.seId=m.seId join financialsecurities f on s.seId=f.seId \n" +
            "join securitiesTradingData se on s.seId=se.seId where se.tranStatus=1 and 1=1 ${condition}")
    public int count(@Param("condition") String condition);
}
